package com.cloud_notes.demo.common.config;

import com.cloud_notes.demo.common.interceptor.UserLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    //注入拦截器
    @Autowired
    private UserLoginInterceptor userLoginInterceptor;

    //重写方法

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(userLoginInterceptor)
                .addPathPatterns("/user/**","/blog/**")//需要的
                .excludePathPatterns("/user/login");//排除
    }
}
